<?php
/**
 * Created by PhpStorm.
 * User: sundy
 * Date: 2020/2/3
 * Time: 10:11
 */

namespace App\Admin\Controllers;

use Encore\Admin\Controllers\AdminController;
use App\Product;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;

class ProductController extends AdminController
{
    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = '套餐';

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new Product);
        $grid->quickSearch('i_product_id','i_boss_product_id','vc_product_name');
        $grid->column('id', __('ID'))->sortable();
        $grid->column('i_product_id', __('Product Id'));
        $grid->column('i_boss_product_id', __('Boss Product Id'));
        $grid->column('vc_product_name', __('Name'));
        $grid->column('f_price', __('Price'));
        $grid->column('i_valid_days', __('Valid Days'));
        $grid->column('vc_zone_name', __('Zone Name'));
        $grid->column('ti_provider', __('Provider'));
        $grid->column('present', __('Present'));

        return $grid;
    }

    /**
     * Make a show builder.
     *
     * @param mixed   $id
     * @return Show
     */
    protected function detail($id)
    {
        $show = new Show(Product::findOrFail($id));

        $show->field('id', __('ID'));
        $show->field('i_product_id', __('Product Id'));
        $show->field('i_boss_product_id', __('Boss Product Id'));
        $show->field('vc_product_name', __('Name'));
        $show->field('f_price', __('Price'));
        $show->field('i_valid_days', __('Valid Days'));
        $show->field('vc_zone_name', __('Zone Name'));
        $show->field('ti_provider', __('Provider'));
        $show->field('present', __('Present'));


        return $show;
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        $form = new Form(new Product);
        $form->text('i_product_id','Product Id')->rules('required');
        $form->text('i_boss_product_id','Boss Product Id')->rules('required');
        $form->text('vc_product_name','Name');
        $form->text('f_price','Price');
        $form->text('i_valid_days','Valid Days');
        $form->text('vc_zone_name','Zone Name');
        $form->text('ti_provider','Provider');
        $form->text('present','Present');
        return $form;
    }



}
